package it.afs.worklog.application;

import it.afs.worklog.persist.hibernate.HibernateDaoFactory;

import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebRequestCycle;

public class HibernateWebRequestCycle extends WebRequestCycle
{
	
	private final HibernateDaoFactory factory;
	
	public HibernateDaoFactory getFactory() {
		return factory;
	}

	public HibernateWebRequestCycle(WebApplication application, WebRequest request, Response response)
	{
		super(application, request, response);
		factory = new HibernateDaoFactory();
	}
	
	@Override
	protected void onBeginRequest()
	{
		super.onBeginRequest();
		factory.beginUnit();
	}
	
	@Override
	protected void onEndRequest()
	{
		super.onEndRequest();
		factory.endUnit();
	}
}